Add SchemaManager::waitForSearchIndexes()#2830
Merged
GromNaN merged 1 commit intodoctrine:2.13.xfrom Sep 30, 2025
Merged
Conversation
074c6cb to
d40615c
Compare
GromNaN
commented
Sep 26, 2025
jmikola
reviewed
Sep 28, 2025
Member
Author
|
I reviewed the full implementation to remove the counting of collection vs search index. In fact when documents are inserted with |
jmikola
reviewed
Sep 29, 2025
| $this->dm->flush(); | ||
|
|
||
| // Write with majority concern to ensure data is visible for search | ||
| $this->dm->flush(['writeConcern' => new WriteConcern(WriteConcern::MAJORITY)]); |
Member
There was a problem hiding this comment.
FWIW, I asked about this in #atlas-search as I couldn't find this discussed in the Atlas Search docs. In any event, no action needed on your part here.
614a5fd to
9eb071c
Compare
9eb071c to
d447ba1
Compare
jmikola
approved these changes
Sep 30, 2025
| $collection = $this->dm->getDocumentCollection($className); | ||
|
|
||
| /** @var array<string, bool> $indexStatus Queryable status for each index name */ | ||
| $indexStatus = array_column(iterator_to_array($collection->listSearchIndexes([ |
Member
There was a problem hiding this comment.
What a marvelous function array_column() is. Thank you, @ramsey.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This method waits until all search indexes for specified (or all) document classes are both queryable and have indexed all documents in their corresponding collections.
$classNames, optional), a maximum wait time in milliseconds ($maxTimeMs, default 10,000 ms), and a delay between checks in milliseconds ($waitTimeMs, default 100 ms).For queryable indexes, it further verifies if all documents have been indexed by comparing the count of indexed documents with the total collection count, using aggregation pipelines appropriate for either(removed because unreliable)'search'or'vectorSearch'index types.$waitTimeMsbefore checking again, until either all indexes are ready or the maximum wait time ($maxTimeMs) is exceeded (in which case an exception is thrown).This addition provides a mechanism for applications to block until search indexes are fully prepared for querying, ensuring consistency and readiness before proceeding with operations that depend on those indexes.
Similar implementation: https://github.com/mongodb-labs/pymongo-search-utils/blob/dddd51f6e1784caa43e0dc66ec8d9487e0762d58/pymongo_search_utils/index.py#L259-L298